/*
 ------------------------------------------------------------------------------
 Copyright (C) 2006-2007 Team Blur.

 This file is part of the Quantum Engine source code.

 The Quantum Engine source code is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or (at your
 option) any later version.

 The Quantum Engine source code is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 more details.

 You should have received a copy of the GNU General Public License along with
 the Quantum Engine source code; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 ------------------------------------------------------------------------------
*/


#ifndef __MEMORY_H__
#define __MEMORY_H__

// Allocates a block of memory of the given size
void *			Mem_Alloc (int size, memoryTag_t tag);

// Allocates a block of memory of the given size and clears it to zero
void *			Mem_ClearedAlloc (int size, memoryTag_t tag);

// Frees a block of memory
void			Mem_Free (const void *ptr);

// Frees all blocks of memory with the given tag
void			Mem_TagFree (memoryTag_t tag);

// Returns the size of the given block of memory
int				Mem_Size (const void *ptr);

// Returns the size of all blocks of memory with the given tag
int				Mem_TagSize (memoryTag_t tag);

// Allocates memory and copies the given string
char *			Mem_CopyString (const char *string, memoryTag_t tag);

// After loading a level, all the allocated memory must be touched to make sure
// it's paged in
void			Mem_TouchMemory (void);

// Statistics for debugging and optimization
void			Mem_PrintStats (void);

// Initializes the memory manager
void			Mem_Init (void);

// Shuts down the memory manager
void			Mem_Shutdown (void);

void *operator new(size_t size,memoryTag_t tag);
void operator delete(void *p,memoryTag_t tag);

#endif	// __MEMORY_H__
